<template>
  <div class="correct">
    <div class="input-container">
      <textarea class="input-area" v-model="textarea"></textarea>
      <div class="input-area">
        <ol class="infinite-list" v-infinite-scroll="load" style="overflow:auto">
          <li v-for="item in result" class="infinite-list-item" :key="item[0]">
            {{item[1]}} → {{item[2]}} 错误位置: {{item[0]+1}}
          </li>
        </ol>
      </div>
    </div>
    <div class="btn">
      <el-button type="primary" icon="el-icon-search" @click="send">开始纠错</el-button>
    </div>
  </div>
</template>

<script>
import { request } from '../network/request'

export default {
  name: "Correct",
  data() {
    return {
      textarea: '',
      result: []
    }
  },
  methods: {
    send() {
      request({
        method: 'post',
        url: '/correct',
        data: {'text': this.textarea}
      }).then(res => {
        console.log(res.data.result);
        this.result = res.data.result;
      })
    },
    load () {
      this.count += 2
    }
  }
};
</script>

<style scoped>
  .correct {
    height: 380px;
    background-color: antiquewhite;
  }
  .input-container {
    display: -webkit-flex;
    display: flex;
    width: 100%;
    justify-content: space-around;
    margin-bottom: 30px;
  }
  .input-area {
    width: 650px;
    height: 290px;
    /* margin: 10px; */
    background-color: aqua;
    border: 2px solid;
    border-radius: 5px;
    font-size: 30px;
    box-shadow: 10px 10px 5px #888888;
  }
</style>